package Demo4;

public class Solution {
    public int maxArea(int[] height) {
    int left = 0;
    int right = height.length - 1;
    int max = 0;
    while(left < right){
        max = Math.max(max,Math.min(height[right],height[left])*(right-left));

        //根据高度大小移动指针
        if(height[left] <= height[right]){
            left++;
        }else{
            right--;
        }

    }
    return max;
    }
}
